package org.reliablesource.prism.gef.editor.commands;

import org.reliablesource.prism.gef.editor.model.ScreenAdapter;
import org.reliablesource.prism.gef.editor.model.WireBendpoint;

public class CreateBendpointCommand extends BendpointCommand {
	private ScreenAdapter screen;
	public CreateBendpointCommand	(final ScreenAdapter _screen){
		screen =  _screen;
	}
	
	public void execute() {
		WireBendpoint wbp = new WireBendpoint();
		wbp.setLocation(super.getLocation());				
		wbp.setRelativeDimensions(getFirstRelativeDimension(),
				getSecondRelativeDimension());
		wbp.setParent(getWire());
		getWire().insertBendpoint(getIndex(), wbp);
		screen.insertBendpoint(getIndex(),wbp);
	}

	public void undo() {
		super.undo();
		WireBendpoint bendPoint = (WireBendpoint) getWire().getBendpoints().get(getIndex());
		screen.removeBendpoint(getIndex(),bendPoint);
		getWire().removeBendpoint(getIndex());

	}

}
